package com.debao.system.service.impl;

import java.util.List;

import com.debao.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.debao.system.mapper.AppointMapper;
import com.debao.system.domain.Appoint;
import com.debao.system.service.IAppointService;

/**
 * 上课预约Service业务层处理
 * 
 * @author DeBao
 * @date 2024-08-30
 */
@Service
public class AppointServiceImpl implements IAppointService 
{
    @Autowired
    private AppointMapper appointMapper;

    /**
     * 查询上课预约
     * 
     * @param id 上课预约主键
     * @return 上课预约
     */
    @Override
    public Appoint selectAppointById(Long id)
    {
        return appointMapper.selectAppointById(id);
    }

    /**
     * 根据用户id和日期查询预约
     * @param id
     * @param date
     * @return
     */
    @Override
    public Appoint selectAppointByAId(Long id, String date,String startAt, String endAt) {
        return appointMapper.selectAppointByAId(id, date,startAt,endAt);
    }

    /**
     * 查询上课预约列表
     * 
     * @param appoint 上课预约
     * @return 上课预约
     */
    @Override
    public List<Appoint> selectAppointList(Appoint appoint)
    {
        return appointMapper.selectAppointList(appoint);
    }

    /**
     * 新增上课预约
     * 
     * @param appoint 上课预约
     * @return 结果
     */
    @Override
    public int insertAppoint(Appoint appoint)
    {
        Long userId = SecurityUtils.getUserId();
        String nickName = SecurityUtils.getNickName();
        appoint.setUserId(userId);
        appoint.setUserName(nickName);
        return appointMapper.insertAppoint(appoint);
    }

    /**
     * 新增上课预约
     *
     * @return 结果
     */
    public void batchInsertAppoint(List<Appoint> appointList){
        appointMapper.batchInsertAppoint(appointList);
    }

    /**
     * 修改上课预约
     * 
     * @param appoint 上课预约
     * @return 结果
     */
    @Override
    public int updateAppoint(Appoint appoint)
    {
        return appointMapper.updateAppoint(appoint);
    }

    /**
     * 批量通过预约
     * @param ids
     * @return
     */
    @Override
    public int batchUpdateAppoint(Long[] ids,Integer status) {
        return appointMapper.batchUpdateAppoint(ids,status);
    }

    /**
     * 批量删除上课预约
     * 
     * @param ids 需要删除的上课预约主键
     * @return 结果
     */
    @Override
    public int deleteAppointByIds(Long[] ids)
    {
        return appointMapper.deleteAppointByIds(ids);
    }

    /**
     * 删除上课预约信息
     * 
     * @param id 上课预约主键
     * @return 结果
     */
    @Override
    public int deleteAppointById(Long id)
    {
        return appointMapper.deleteAppointById(id);
    }
}
